package com.jiejie.service.impl;

import com.jiejie.entity.CustomerAndCoupon;
import com.jiejie.mapper.CustomerAndCouponMapper;
import com.jiejie.service.ICustomerAndCouponService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 辰广
 * @since 2022-10-05
 */
@Service
public class CustomerAndCouponServiceImpl extends ServiceImpl<CustomerAndCouponMapper, CustomerAndCoupon> implements ICustomerAndCouponService {
@Autowired
private CustomerAndCouponMapper customerAndCouponMapper;
    @Override
    public Integer receiveCouForCustomer(Integer couponId, Integer custId) {
        CustomerAndCoupon customerAndCoupon=new CustomerAndCoupon();
        customerAndCoupon.setCouponId(couponId);
        customerAndCoupon.setCustomerId(custId);
        customerAndCoupon.setCustomerAndCouponStart(LocalDateTime.now());
        customerAndCoupon.setCustomerAndCouponValit(LocalDateTime.now().plusDays(1));
        customerAndCoupon.setCustomerAndCouponStatus(0);
       int rows= customerAndCouponMapper.insert(customerAndCoupon);
        return rows;
    }
}
